#include "bullet.h"

Bullet::Bullet()
{
    m_Bullet.load(BULLET_PATH);
    m_x=gamewidth*0.5-m_Bullet.width();
    m_y=gameheight;
    m_Free=true;
    m_speed=BULLET_SPEED;
    m_Rect.setWidth(m_Bullet.width());
    m_Rect.setHeight(m_Bullet.height());
    m_Rect.moveTo(m_x,m_y);
}

void Bullet::updatePosition()
{
    if(m_Free)
    {
        return;
    }
    m_y -=m_speed;
    m_Rect.moveTo(m_x,m_y);
    if(m_y<=-m_Rect.height())
    {
        m_Free=true;
    }
}
